home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cpp_libs / cool / cool.lha / lice / misc / defs / misc.h < prev   
Encoding:
C/C++ Source or Header  |  1991-09-04  |  3.6 KB  |  121 lines

  1. //
  2. //
  3. // Copyright (C) 1991 Texas Instruments Incorporated.
  4. //
  5. // Permission is granted to any individual or institution to use, copy, modify,
  6. // and distribute this software, provided that this complete copyright and
  7. // permission notice is maintained, intact, in all copies and supporting
  8. // documentation.
  9. //
  10. // Texas Instruments Incorporated provides this software "as is" without
  11. // express or implied warranty.
  12. //
  13. // This file  contains  useful definitions,  macros, and constants used through
  14. // out most header and source files.
  15. //
  16.  
  17. #ifndef MISCELANEOUSH                // If no miscelaneous header
  18. #define MISCELANEOUSH
  19.  
  20. #ifndef DEFSH
  21. #include <defs.h>                // Include the defs header
  22. #endif
  23.  
  24. #if defined(MSDOS) && !defined(DOS)        // For IBM or MS compilers
  25. #define DOS
  26. #endif
  27.  
  28. #ifndef INVALID                    // Define INVALID for curpos
  29. #define INVALID (-1)
  30. #endif
  31.  
  32. #ifndef END_OF_STRING                // If END_OF_STRING not defined
  33. #define END_OF_STRING (0)
  34. #endif
  35.  
  36. #ifndef NEWLINE                    // If Newline char not defined
  37. #define NEWLINE '\n'
  38. #endif
  39.  
  40. #ifndef SENSITIVE                // If case flags not defined
  41. #define SENSITIVE TRUE
  42. #define INSENSITIVE FALSE
  43. #endif
  44.  
  45. #ifndef BITSPERBYTE                // Machine bits per byte macros
  46. #define BITSPERBYTE 8
  47. #define BITS(type) (BITSPERBYTE * (int)sizeof(type))
  48. #define MINSHORT  ((short)(1 << BITS(short) - 1))
  49. #define MININT  (1 << BITS(int) - 1)
  50. #define MINLONG  (1L << BITS(long) - 1)
  51. #define MAXSHORT ((short)~MINSHORT)
  52. #define MAXINT  (~MININT)
  53. #define MAXLONG (~MINLONG)
  54. #endif
  55.  
  56. #ifndef NUMBER_STATES
  57. #define NUMBER_STATES
  58. enum N_status { N_OK, N_MINUS_INFINITY, N_PLUS_INFINITY, N_OVERFLOW,
  59.         N_UNDERFLOW, N_NO_CONVERSION, N_DIVIDE_BY_ZERO };
  60. #endif
  61.  
  62. #ifndef MAXDOUBLE
  63. #if pdp11 || vax                // Vaxen do it their own way...
  64. #define MAXDOUBLE    1.701411834604692293e+38
  65. #define MAXFLOAT    ((float)1.701411733192644299e+38)
  66. /* The following is kludged because the PDP-11 compilers botch the simple form.
  67.    The kludge causes the constant to be computed at run-time on the PDP-11,
  68.    even though it is still "folded" at compile-time on the VAX. */
  69. #define MINDOUBLE    (0.01 * 2.938735877055718770e-37)
  70. #define MINFLOAT    ((float)MINDOUBLE)
  71. #define _IEEE        0
  72. #define _DEXPLEN    8
  73. #define _HIDDENBIT    1
  74. #define DMINEXP    (-DMAXEXP)
  75. #define FMINEXP    (-FMAXEXP)
  76. #else                        // IEEE floating point
  77. #define MAXDOUBLE    1.79769313486231470e+308
  78. #define MAXFLOAT    ((float)3.40282346638528860e+38)
  79. #define MINDOUBLE    4.94065645841246544e-324
  80. #define MINFLOAT    ((float)1.40129846432481707e-45)
  81. #define    _IEEE        1
  82. #define _DEXPLEN    11
  83. #define _HIDDENBIT    1
  84. #define DMINEXP    (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
  85. #define FMINEXP    (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
  86. #endif
  87. #endif
  88.  
  89. #ifndef ABS
  90. #define ABS(x) ((x >= 0) ? (x) : (-x))
  91. #endif
  92.  
  93. // even --  Determine if long integer is odd of even
  94. // Input:   long integer
  95. // Output:  Boolean TRUE/FALSE
  96.  
  97. inline Boolean even (long n) {
  98.   return ((n & 1) ? FALSE : TRUE);
  99. }
  100.  
  101. // odd --  Determine if long integer is odd of even
  102. // Input:  long integer
  103. // Output: Boolean TRUE/FALSE
  104.  
  105. inline Boolean odd (long n) {
  106.   return ((n & 1) ? TRUE : FALSE);
  107. }
  108.  
  109. // The "#pragma defmacro" is a COOL extension to the standard  ANSI C processor
  110. // that allows  a programmer to  define macro  extensions to the  language. All
  111. // COOL  macros   have  been  incorporated  into  the preprocessor   itself  to
  112. // facilitate extra speed and efficiency. User defined  extensions are searched
  113. // for on the include file path.
  114.  
  115. #pragma defmacro MACRO "macro" delimiter=} recursive
  116. #pragma defmacro template "template" delimiter=}
  117. #pragma defmacro DECLARE "declare" delimiter=> recursive lines
  118. #pragma defmacro IMPLEMENT "implement" delimiter=> recursive lines
  119.  
  120. #endif MISCELANEOUSH                // End #ifdef
  121.